package com.zhuoyue.biz.core.command.cmd.common.faa;

import com.zhuoyue.biz.core.api.domain.DeviceAndGatewayDO;
import com.zhuoyue.biz.core.api.dto.req.ControlReq;
import com.zhuoyue.biz.core.command.cmd.common.faa.base.ControlCmd;
import com.zhuoyue.biz.core.command.cmd.common.faa.base.SceneModeEnum;
import com.zhuoyue.common.constant.DataBase;

import static com.zhuoyue.common.constant.ControlType.Set.SCENE_SET_REQUEST;

/**
 * 液晶场景控制器场景配置方法
 * @ClassName: IntelligentSceneController0FAA8A04
 * @Description:
 * @author wjming
 * @Date 2021-07-15 14:21
 */
public class IntelligentSceneController0Faa8A04 extends ControlCmd {
    private static Integer setRoad = null;

    /**
     * @param deviceAndGatewayDO
     * @param controlReq         action{
     *                           "sceneId":"xxxxxx",
     *                           "setRoad":1,
     *                           "sceneMode":"GoHome"
     *                           }
     * @param codeStr
     * @return
     */
    public static String set(DeviceAndGatewayDO deviceAndGatewayDO, ControlReq controlReq, String codeStr) {
        setRoad = (Integer) controlReq.getActions().get("setRoad");
        String mode = controlReq.getActions().get("sceneMode") + "";
        String cmd = "";
        switch (controlReq.getControlType()) {
            case SCENE_SET_REQUEST:
                //场景配置
                cmd = getControlCmd(deviceAndGatewayDO, sceneSet(codeStr, mode));
                break;
            default:
                break;
        }
        return cmd;
    }

    private static String sceneSet(String code, String sceneMode) {
        return setRoad < 10 ? 0 + "setRoad" : setRoad + "" + DataBase.DATA_LENGTH_12 + code + "FE" + SceneModeEnum.getSceneModeEnum(sceneMode);
    }
}
